package com.example.test;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private EditText name;
    private EditText password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.button).setOnClickListener(this);
        name = findViewById(R.id.namer);
        password = findViewById(R.id.password);
    }

    @Override
    public void onClick(View view) {
        String name1 = name.getText().toString();
        String pass1 = password.getText().toString();
        if (name1.equals("xiaohong") && pass1.equals("123456")) {
            Toast.makeText(this, "恭喜您，登陆成功", Toast.LENGTH_SHORT).show();
            Intent intent=new Intent(this,SecondActivity.class);
            startActivity(intent);
        } else {
            Toast.makeText(this, "用户名或密码输入错误", Toast.LENGTH_SHORT).show();
        }
    }
}
